home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Garbo
/
Garbo.cdr
/
mac
/
source
/
music4c.sit
/
Music4C Folder
/
orchestras
/
ReadSD_1_File.c
< prev
next >
Wrap
Text File
|
1990-09-11
|
3KB
|
129 lines
/* this instrument just reads in a Sound Designer¬ format sound file
and outputs it as a stereo file.
*/
/*
* ⌐ Graeme Gerrard 1990
* Faculty of Music, University of Melbourne
* Parkville Victoria 3052 Australia.
*
* ARPANET: grae@murdu.ucs.unimelb.edu.au
* telephone: (613) 344 4127, Fax: (613) 344 5104
*/
#define READTYPE 1 /* type of instrument */
#include <math.h>
#include "Music4c.h"
#include "ugens.h"
#include "orch.h"
#include "Music4C_Prototype.h"
static double E_buf[512];
static int E_buflen;
static double E_ptr;
static double E_si;
static double InSig;
static double OutSig;
static ParmBlkPtr E_myPBlkPtr;
static ParamBlockRec E_myPBlk;
static long StartSamp, EndSamp;
static double SampPtr;
Boolean SetSFDir(Str255, long *);
extern long SoundFileDirID;
extern Str255 SFDirectoryName;
extern Str255 theMess1;
extern OSErr theErr;
extern DialogPtr thePass3DialogPtr;
extern void DisplayDialog(DialogPtr);
void initl()
{
Point where;
SFTypeList types;
SFReply theFileReply;
long nBytes;
E_buflen = 512;
E_myPBlkPtr = &E_myPBlk;
/* set up soundfile directory*/
SetSFDir(SFDirectoryName, &SoundFileDirID);
SetPt(&where, 100, 100);
types[0] = 'SFIL';
SFGetFile(where, NIL, NIL, 1, types, NIL, &theFileReply);
if(!theFileReply.good) {
FixUp();
CleanUp(FALSE);
}
DisplayDialog(thePass3DialogPtr);
E_myPBlkPtr->ioParam.ioNamePtr = (StringPtr)theFileReply.fName;
E_myPBlkPtr->ioParam.ioVRefNum = NIL;
E_myPBlkPtr->ioParam.ioVersNum = NIL;
E_myPBlkPtr->ioParam.ioPermssn = fsRdPerm;
theErr = PBOpen(E_myPBlkPtr, FALSE);
if ( theErr != noErr ) {
PstringCopy((char *)theMess1, "\pError opening file");
OSError(theMess1, theFileReply.fName, theErr);
}
E_myPBlkPtr->ioParam.ioCompletion = NIL;
PBGetEOF(E_myPBlkPtr, FALSE);
nBytes = (long)E_myPBlkPtr->ioParam.ioMisc;
}
void setup()
{
switch( instype ) {
case READTYPE:
E_si = p[4]; /* sample increment */
SampPtr = p[5]; /* start sample in file */
StartSamp = (long)SampPtr;
if ( !SF_SD_1_ReadSet( E_buf, E_buflen, &E_ptr, E_myPBlkPtr, &SampPtr, &StartSamp, &EndSamp) ) {
fprintf(stderr,"bad file name?\n");
}
OutSig = 0.0;
InSig = 0.0;
break;
default:
fprintf(stderr, "Wrong file type\n");
}
}
void orch()
{
switch( instype ) {
case READTYPE:
InSig = SF_SD_1_Read(E_myPBlkPtr, E_si, E_buf, E_buflen, &E_ptr, &SampPtr, &StartSamp, &EndSamp);
OutSig = InSig;
/* mono(OutSig);*/
Stereo(OutSig, 0.5);
break;
default:
fprintf(stderr, "Wrong instrument type\n");
}
}
void ter()
{
}
void final()
{
/* called at the end of the synth run.
* close any files etc. you haven't already closed here.
*/
PBClose(E_myPBlkPtr, FALSE);
}